package reco.db.validation;

import reco.db.Constraint;
import reco.db.Field;

/**
 * Creates {@link NotBlankConstraint} instances.
 */
public class NotBlankConstraintFactory extends SimpleConstraintFactory implements StringConstraintFactory {
    public NotBlankConstraintFactory() {
        super(String.class);
    }

    /**
     * Creates {@link NotNullConstraint} instances.
     * 
     * @param field
     *            {@link Field} over which the constraint will be applied.
     * @return a {@link NotNullConstraint} constraint on field.
     * @throws NullPointerException
     *             if field is <code>null</code>.
     * @throws IllegalArgumentException
     *             if field does not hold String values.
     */
    @Override
    protected <T> Constraint<T> createConstraint() {
        @SuppressWarnings("unchecked")
        // we already now T is String
        final Constraint<T> constraint = (Constraint<T>) new NotBlankConstraint();

        return constraint;
    }
}
